* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 600px;
  width: 380px;
}

.container {
  background: white;
  border-radius: 12px;
  margin: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  text-align: center;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.header-controls {
  display: flex;
  gap: 8px;
}

.theme-btn, .export-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.theme-btn:hover, .export-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.sync-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 auto;
  transition: all 0.3s ease;
}

.sync-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.sync-icon {
  animation: none;
}

.sync-btn.syncing .sync-icon {
  animation: rotate 1s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.search-section {
  padding: 20px 20px 10px;
}

.filter-section {
  margin-top: 15px;
}

.tag-filters-container {
  position: relative;
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  transition: all 0.3s ease;
  overflow: hidden;
}

.tag-filters.collapsed {
  max-height: 60px; /* 约显示2-3行标签 */
}

.tag-filters.expanded {
  max-height: none;
}

.tag-filter {
  background: #f0f0f0;
  border: 1px solid #e1e5e9;
  color: #666;
  padding: 4px 8px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.3s ease;
}

.tag-filter:hover {
  background: #e1e5e9;
}

.tag-filter.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.tag-toggle-btn {
  background: none;
  border: none;
  color: #667eea;
  cursor: pointer;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 15px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.3s ease;
  width: auto;
  margin-left: auto;
  margin-right: auto;
}

.tag-toggle-btn:hover {
  background: rgba(102, 126, 234, 0.1);
  transform: translateY(-1px);
}

.toggle-icon {
  font-size: 10px;
  transition: transform 0.3s ease;
}

.tag-toggle-btn.expanded .toggle-icon {
  transform: rotate(180deg);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

#searchInput {
  width: 100%;
  padding: 12px 40px 12px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 25px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s ease;
}

#searchInput:focus {
  border-color: #667eea;
}

.clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.clear-btn:hover {
  background: #f0f0f0;
  color: #666;
}

.stats {
  display: flex;
  justify-content: space-between;
  padding: 0 20px 15px;
  font-size: 12px;
  color: #666;
}

.bookmark-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 0 20px 20px;
}

.bookmark-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.bookmark-item:hover {
  background: #f8f9fa;
  border-color: #e1e5e9;
  transform: translateY(-1px);
}

.bookmark-favicon {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}

.bookmark-info {
  flex: 1;
  min-width: 0;
}

.bookmark-title {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-url {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-folder {
  font-size: 11px;
  color: #999;
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-hint {
  font-size: 12px;
  color: #999;
  margin-top: 8px;
}

.loading {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.bookmark-list::-webkit-scrollbar {
  width: 6px;
}

.bookmark-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.bookmark-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.bookmark-list::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.highlight {
  background-color: #fff3cd;
  padding: 1px 2px;
  border-radius: 2px;
}

.bookmark-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.bookmark-tag {
  background: #e3f2fd;
  color: #1976d2;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 500;
}

/* 暗色主题 */
body.dark-theme {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

body.dark-theme .container {
  background: #2c3e50;
  color: #ecf0f1;
}

body.dark-theme .header {
  background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
}

body.dark-theme #searchInput {
  background: #34495e;
  border-color: #4a5f7a;
  color: #ecf0f1;
}

body.dark-theme #searchInput:focus {
  border-color: #667eea;
}

body.dark-theme .bookmark-item {
  background: #34495e;
  border-color: #4a5f7a;
}

body.dark-theme .bookmark-item:hover {
  background: #3d566e;
}

body.dark-theme .bookmark-title {
  color: #ecf0f1;
}

body.dark-theme .bookmark-url {
  color: #bdc3c7;
}

body.dark-theme .bookmark-folder {
  background: #4a5f7a;
  color: #bdc3c7;
}

body.dark-theme .stats {
  color: #bdc3c7;
}

body.dark-theme .tag-filter {
  background: #4a5f7a;
  border-color: #5d6d7e;
  color: #bdc3c7;
}

body.dark-theme .tag-filter:hover {
  background: #5d6d7e;
}

body.dark-theme .tag-filter.active {
  background: #667eea;
  color: white;
}

body.dark-theme .clear-btn:hover {
  background: #4a5f7a;
  color: #ecf0f1;
}

body.dark-theme .tag-toggle-btn {
  color: #94a3b8;
}

body.dark-theme .tag-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}